#ifndef QTSTRA_TEMPLATE_H
#define QTSTRA_TEMPLATE_H


#include <QTabWidget>
#include "QtInstrument.h"
#include "QtStra_Xml.h"
#include "QtStra_Thread.h"
#include "QtStra_Userdata.h"


class QDockWidget;
class QSplitter;
class QTableWidget;
class QPushButton;
class QTabWidget;


class QtStraTemplate : public QTabWidget
{
	Q_OBJECT

public:
	QtStraTemplate(int straindex, QDockWidget* instDock, QDockWidget* strategyDock, QTabWidget::TabPosition pos = QTabWidget::South, QWidget *parent = 0);

	void CreateThread();

	void DestroyThread();

	void OnUpdateInstDockAndStrategyDock();

	void OnDestroyAllBars();

	void OnReinitAllBars();

	void OnTimer(TimerFire_namespace::TimerFireType timertype);


	virtual QString DefaultInstTableValue(int col) = 0;

protected:

	void SetInstTable(QTableWidget* instTable);

	void InitInstTable();

private:

	void CreateStrategyInfo(QDockWidget* strategyDock);

	void CreateInstInfo(QDockWidget* instDock);


	void ReadXml();

	void WriteXml();

	

	void Edit_Del_AddInst(TimerFire_namespace::TimerFireType timertype);
	bool AddInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata);
	bool DelInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata);
	bool EditInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata);


	void StartCtl(TimerFire_namespace::TimerFireType timertype = TimerFire_namespace::invalid);

	virtual void SetUserdataNew() = 0;

	 
private slots:

	void OnctlBtnClicked();

	void OneditBtnClicked();

	void OnreadxmlBtnClicked();

	void OnwritexmlBtnClicked();

	void OnSlotInit(BarSeries* pBarSer, BarData* pData);

	void OnSlotDestroy(BarInfo* pbar);

	void OnSlotSysMd(BarData* pData);


protected:

	//QTableWidget *m_instTable;


	QtStraUserdata* m_pstrauserdata;

	
private:

	//m_instDock and elements in it
	QDockWidget* m_instDock;
	QSplitter* m_instSplitter;
	QTableWidget *m_instTable;
	QPushButton *m_ctlBtn;
	QPushButton *m_editBtn;
	QPushButton *m_readXmlBtn;
	QPushButton *m_writeXmlBtn;


	//m_strategyDock  and elements in it
	QDockWidget* m_strategyDock;
	QtStraStrategyInfo* m_strategyinfo;

	string m_xmlfile;

	QtStraXml* m_xml;

	QtStraThread* m_thread;

	//from 1
	int m_straindex;

	


};




#endif
